﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList array = new ArrayList();

            array.Add("云服务以上线");//添元素
            array.Add("23");
            array.Add("sunshine");

            for (int i = 0; i < array.Count; i++)//遍历
            {
                Console.WriteLine(array[i]);
            }

            string[] str = { "张一", "张二", "张三", "张力" };

            array.AddRange(str);//集合中添加集合


            Console.WriteLine("删了前有{0}个元素", array.Count);
            foreach (object obj in array)
            {
                Console.WriteLine(obj + "\t");
            }


            array.RemoveRange(4, 2);//从第4位移除2个元素
            Console.WriteLine("现在还剩{0}个元素", array.Count);
            foreach (object obj in array)
            {
                Console.WriteLine(obj + "\t");
            }


            array.Clear();//清空
            Console.WriteLine("这搞一下清空就剩{0}个元素", array.Count);
            foreach (object obj in array)
            {
                Console.WriteLine(obj + "\t");
            }
        }
    }
}
